Function.prototype.bind3=function(context){
    var self=this;
    var args=Array.prototype.slice.call(arguments,1);
    var fBound=function(){
        var bindArgs=Array.prototype.slice.call(arguments);
        return self.apply(this instanceof fBound?this:context,args.concat(bindArgs));
    }
    fBound.prototype=this.prototype;
    return fBound;
}

var foo={
    value:1
}
function bar(name,age){
    console.log(this.value)
    console.log(name)
    console.log(age)
    this.friend='xiaofeng'
}
bar.prototype.habbit='shopping'
var resultFoo=bar.bind3(foo,'zhangsan')
var obj=new resultFoo(11)
console.log(obj.habbit)
console.log(obj.friend)